<template>
  <authorization>
    <view class="culturedetail">
      <view class="main">
        <view class="culturedetail-title">{{ datas.title }}</view>
        <!-- <view class="culturedetail-title">{{datas.title}}</view> {{
              gettime
            }}-->

        <view class="info">
          <view class="info-row" style="width: 40%">
            <image :src="timeicon" class="icon" alt="" srcset="" /><text>{{
              gettime
            }}</text>
          </view>
          <view class="info-row" style="width: 20%; text-align: center">
            <image :src="timeicon" class="icon" alt="" srcset="" /><text>{{
              datas.name
            }}</text>
          </view>
          <view class="info-row" style="width: 40%; text-align: end">
            <image :src="timeicon" class="icon" alt="" srcset="" /><text>{{
              datas.visit_count
            }}</text>
          </view>
        </view>

        <view class="content">
          <rich-text :nodes="datas.content"></rich-text>
        </view>
      </view>

      <!-- 11111111 -->
    </view>
  </authorization>
</template>

<script>
import "./index.scss";
import Taro, { getCurrentInstance } from "@tarojs/taro";
import timeicon from "../../../assets/icon/timeicon.png";
import formatTime from "../../../utils/formatTime";
import authorization from "../../../components/authorization";
import request from "../../../utils/request";

export default {
  components: {
    authorization: authorization,
  },
  data() {
    return {
      detailId: "",
      timeicon: timeicon,
      datas: {
        title: "",
        dtt: "",
        name: "管理员",
        visit_count: 0,
      },
    };
  },
  computed: {
    // 计算属性的 getter
    gettime: function () {
      // `this` 指向 vm 实例
      const time = this.datas.dtt;
      // var currenttime= res.data.timeStamp;

      return formatTime(time, "yyyy-mm-dd h:m");
    },
  },
  created() {
    console.log(getCurrentInstance().router.params.id, "2342");
    this.detailId = getCurrentInstance().router.params.id;
    this.getArticlesDetail();
  },
  // articles/5cf47d251c4d3d2c0c215225.htm
  mounted() {},
  methods: {
    getArticlesDetail() {
      request("get", `/api/rest/articles/${this.detailId}.htm`).then((res) => {
        this.datas = res;
        console.log("sdasda", this.datas.name);
        this.datas.name = ("" == this.datas.name || undefined == this.datas.name) ? "管理员" : this.datas.name;
        wx.setNavigationBarTitle({
          title: res.category_id.name,
        });
      });
    },
  },
};
</script>

<style>
.culture-swiper {
  width: 100%;
  height: 300rpx;
}
</style>